<?php

/**
 * Error reporting and display
 *
 * Error reporting sets the level of error that must be met in order for an
 * error to actually be thrown during script execution. This value should be set
 * to one of PHP's E_* constants. See http://php.net/error_reporting for more
 * information.
 *
 * The display_errors ini setting determines whether or not PHP errors will be
 * displayed during script execution. It can help to reduce debugging time and
 * should be set to 'On' during development. However, once deployed this value
 * should be changed to 'Off'.
 */
error_reporting(E_ALL);
ini_set('display_errors', 'On');

/**
 * Output compression
 *
 * Enables compression of output if the client supports it.
 */
ini_set('zlib.output_compression', 'On');

/**
 * Application directory
 *
 * Set this to the full system path of the application directory with no
 * trailing slash.
 */
define('APP_DIR', dirname(__FILE__) . '/app');

/**
 * Majic directory
 *
 * Set this to the full system path of the majic directory with no
 * trailing slash.
 */
define('MJ_DIR', dirname(dirname(dirname(__FILE__))) . '/majic');
require_once MJ_DIR . '/Majic.php';

/**
 * Base url
 *
 * The base url of the index.php file. Must end with a slash.
 */
$config['base_url'] = 'http://localhost/majic/app/';

/**
 * Base file
 *
 * This is the name of the index.php file at the base of the installation. If
 * using a .htaccess file to remove this from the url, it can be left blank.
 */
$config['base_file'] = 'index.php';

/**
 * Extension
 *
 * This is an extension that will be appended to all automatically generated
 * URL's and likewise stripped from the end of all request strings to determine
 * controller/method combinations.
 */
$config['extension'] = 'php';

/**
 * Allowed URI characters
 *
 * Specifies which characters are allowed in a URI string.
 */
$config['allowed_uri_characters'] = 'a-z 0-9~%.:_-';

/**
 * Routes
 *
 * The keys of this array are regular expressions that are used to match the
 * controller/method specified in the request string. The routes will be applied
 * in the order given. Note that there should be one entry here that will serve
 * up the default controller/method in the case of an empty string. Also note
 * that if no method is specified, the default "index" method of the controller
 * will be used.
 */
$config['routes'] = array(
    '/^$/' => 'main/index'
);

/**
 * Log variables
 *
 * log_path                 = The path to the error log files (with a trailing
 *                            slash). If left blank, logs will be written to
 *                            app/logs.
 * log_threshold            = The threshold that determines which messages will
 *                            be logged. May be one of the following:
 *
 *                            0     No logging
 *                            1     Error messages (including PHP errors)
 *                            2     Debug messages
 *                            3     Info messages
 *                            4     All messages
 *
 * log_date_format          = The date format to use in log entries. See
 *                            http://php.net/date for further information.
 */
$config['log_path']         = '';
$config['log_threshold']    = 4;
$config['log_date_format']  = 'Y-m-d H:i:s';

/**
 * Application-specific configuration
 *
 * Application-wide (global) parameters may be defined here.
 */

/**
 * Start the system
 */

// load config parameters
foreach ($config as $key => $value) {
    Majic::setConfig($key, $value);
}
unset($config);

// route the request
Majic::run();

// send output
$view = View::getInstance();
$view->send();

?>